package Luogu;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class P1908 {
    static int[] a;
    static int[] b;
    static long ans = 0;

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        a = new int[n + 1];
        b = new int[n + 1];
        String tmp = br.readLine();
        String[] nums = tmp.split(" ");
        for (int i = 1; i <= n; i++) {
            a[i] = Integer.parseInt(nums[i - 1]);
        }
        GuiSort(1, n);
        System.out.println(ans);
    }

    public static void GuiSort(int left, int right) {
        if (left == right)
            return;
        int mid = (left + right) >>> 1;
        int index = left;
        int leftTmp = left;
        int rs = mid + 1;
        GuiSort(left, mid);
        GuiSort(mid+1, right);
        while (leftTmp <= mid && rs <= right) {
            if (a[leftTmp] <= a[rs]) {
                b[index++] = a[leftTmp++];
            } else {
                b[index++] = a[rs++];
                ans += mid - leftTmp +1;
            }
        }
        while(leftTmp <= mid){
            b[index++] = a[leftTmp++];
        }
        while(rs <= right){
            b[index++] = a[rs++]; 
        }
        for(int i = left;i<=right;i++){
            a[i] = b[i];
        }
    }
}
